fix: use QJsonObject for event logger messages#187
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideRefactors EventLoggerData to store event messages as a QJsonObject instead of a string map so structured JSON payloads are preserved, and simplifies EventLogger by removing the now-mismatched string key/value helper and serializing the stored QJsonObject directly. Class diagram for updated EventLoggerData and EventLoggerclassDiagram
class EventLoggerData {
qint64 tid
QString target
QJsonObject message
EventLoggerData()
EventLoggerData(qint64 tid, const QString &target, const QJsonObject &message)
}
class EventLogger {
void writeEventLog(const EventLoggerData &data)
bool init(QString package_id, bool enable_sig)
QJsonDocument toJson(EventLoggerData data)
}
EventLogger --> EventLoggerData : uses
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- If simple key/value logging is still a common case, consider keeping a convenience
writeEventLog(tid, target, key, value)that internally constructs aQJsonObjectso existing call sites don’t all have to manually build JSON objects. - Since
EventLoggerData::messagechanged type, double-check any implicit uses (e.g., brace-initialization with{ {"key", "value"} }) still behave as intended withQJsonObject, or consider adding explicit factory/helpers to make the new usage pattern clearer.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- If simple key/value logging is still a common case, consider keeping a convenience `writeEventLog(tid, target, key, value)` that internally constructs a `QJsonObject` so existing call sites don’t all have to manually build JSON objects.
- Since `EventLoggerData::message` changed type, double-check any implicit uses (e.g., brace-initialization with `{ {"key", "value"} }`) still behave as intended with `QJsonObject`, or consider adding explicit factory/helpers to make the new usage pattern clearer.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
402e4c9 to
4eed94c
Compare
为 EventLogger 添加 cmake find_package 支持和自动初始化 - Add DDEAPIConfig.cmake for find_package(DdeApi) - Auto-init with DSGApplication::id() when not explicitly initialized - Use QJsonObject for structured event log messages - Refactor init logic into doInit() method - Install cmake config to /usr/share/cmake/DDEAPI/ PMS: TASK-388657
4eed94c to
208c3fc
Compare
deepin pr auto review这份代码变更主要涉及了三个部分:CMake配置文件的添加、Makefile的修改以及C++头文件的重构。我将从语法逻辑、代码质量、代码性能和代码安全四个方面进行审查。 1. 语法逻辑CMake配置文件 (
Makefile:
C++头文件 (
2. 代码质量C++头文件:
3. 代码性能
4. 代码安全
总结与建议
这些改进将使代码更健壮、更易于维护,并在不同环境下表现更一致。 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, Ivy233 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Use QJsonObject directly for EventLoggerData messages so JSON payloads are preserved when writing event logs. Remove the string key/value helper that no longer matches the object-based message payload.
使用 QJsonObject 直接承载 EventLoggerData 的 message 字段,确保写入事件日志时保留 JSON 载荷内容。移除不再匹配对象化 message 载荷的字符串键值辅助接口。
Summary by Sourcery
Switch event logger message payloads to use QJsonObject instead of string maps to preserve structured JSON data.
Bug Fixes:
Enhancements: